<!--
 * @Descripttion: 
 * @version: @ 1.0.0
 * @Author: 朱江洲
 * @Date: 2021-09-18 09:42:12
 * @LastEditors: 朱江洲
 * @LastEditTime: 2022-05-12 16:23:51
-->
<template>
  <div>
    <div class="content">
      <el-form
        :model="userInfo"
        ref="userInfo"
        :rules="infoRules"
        label-width="80px"
        :inline="false"
      >
        <el-form-item label="账户名称">
          <el-input
            v-model="userInfo.nickName"
            placeholder="请输入账户名称"
            size="normal"
            style="width: 330px"
          ></el-input>
        </el-form-item>
        <el-form-item label="手机号码">
          <el-input
            v-model="userInfo.phonenumber"
            disabled
            style="width: 330px"
          ></el-input>
        </el-form-item>
        <el-form-item label="所属部门">
          <el-input v-model="deptName" disabled style="width: 330px"></el-input>
        </el-form-item>
        <el-form-item label="直属上级">
          <el-input
            v-model="userInfo.parentName"
            disabled
            style="width: 330px"
          ></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-select v-model="userInfo.sex" style="width: 330px">
            <el-option
              v-for="item in sexOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import userAvatar from "../../../system/user/profile/userAvatar.vue";
import { profile, updateProfile } from "@/api/user";
export default {
  components: { userAvatar },
  props: {
    dialog: {
      type: Object,
      required: true,
    },
    userInfo: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      deptName: "",
      // userInfo: {},
      user: {},
      infoRules: {},
      sexOptions: [
        {
          value: "0",
          label: "男",
        },
        {
          value: "1",
          label: "女",
        },
      ],
    };
  },
  created() {
    // this.getUserInfo();
  },
  methods: {
    onSubmit() {
      updateProfile({
        nickName: this.userInfo.nickName,
        sex: this.userInfo.sex,
      }).then((res) => {
        this.$message.success(res.msg);
        this.dialog.nickNameShow = false;
         this.$store.dispatch("GetInfo")
        this.$emit("getIf");
      });
    },
    getUserInfo() {
      profile().then((res) => {
        this.userInfo = res.data;
        this.deptName = res.data.dept.deptName;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.app-container {
  padding: 24px 25px;
  .header {
    .info {
      font-size: 0.1rem;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #2b2b2b;
    }
  }
  .content {
    margin-top: 40px;
  }
  .portrait {
    height: 123px;
    /deep/ .el-form-item__label {
      margin-top: 50px;
    }
    .portrait-size {
      margin-left: 50px;
      width: 123px;
      height: 123px;
      border-radius: 123px;
      img {
        width: 100%;
        height: 100%;
        border-radius: 123px;
      }
    }
  }
}
</style>